
  <?php
  /*
  name:    updateGlobeDB
  utility: use to update date in the 'globe' table
  input:   $db, database login parameters
		   $userID, key of the user device
		   $lat_cell, latitude of the cellule where we have to add a user
		   $lon_cell, longitude of the cellule where we have to add a user
		   $country, name of the country where the data is send from
		   $existe, true if the key already exist in the table, false alternatively
   output: nothing
   more:   for the v1 beta version, a key can appear more than once in the table,
		   but in the final v1 version, each key will appear only once
   */
  
  //function updateGlobeDB($db, $userID, $lat_cell, $lon_cell, $country, $existe)
  function updateGlobeDB($db, $userID, $lat_cell, $lon_cell, $existe)
  {
      //if the key is already in the table, we just update it
      //else we insert a new line in the table
      if($existe)
       {
       //$req = $db->prepare('UPDATE globe SET lat_cell = :lat_cell, lon_cell = :lon_cell country = :country WHERE userID = :userID');
	   $req = $db->prepare('UPDATE globe SET lat_cell = :lat_cell, lon_cell = :lon_cell WHERE userID = :userID');
       $req->execute(array(
       'userID' => $userID,
       'lat_cell' => $lat_cell,
       'lon_cell' => $lon_cell
	   //'country' => $country
       ));
       echo "update of the globe table".'</br>';
       
       }
       else
       {
//      $req = $db->prepare('INSERT INTO globe(userID, lat_cell, lon_cell, country) VALUES(:userID, :lat_cell, :lon_cell, :country)');
	  $req = $db->prepare('INSERT INTO globe(userID, lat_cell, lon_cell) VALUES(:userID, :lat_cell, :lon_cell)');
        $req->execute(array(
       'userID' => $userID,
       'lat_cell' => $lat_cell,
       'lon_cell' => $lon_cell,
	   //'country' => $country
       ));
      echo "insert a new line in the globe table" . '</br>';
      }
  }
?>